home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / TranslationExtensions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  6.1 KB  |  185 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        TranslationExtensions.h
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __TRANSLATIONEXTENSIONS__
  21. #define __TRANSLATIONEXTENSIONS__
  22.  
  23. #define kSupportsFileTranslation        1
  24. #define kSupportsScrapTranslation        2
  25. #define kTranslatorCanGenerateFilename    4
  26.  
  27. #ifndef REZ
  28.  
  29. #ifndef __MEMORY__
  30. #include <Memory.h>
  31. #endif
  32. /*    #include <Types.h>                                            */
  33. /*        #include <ConditionalMacros.h>                            */
  34. /*    #include <MixedMode.h>                                        */
  35.  
  36. #ifndef __FILES__
  37. #include <Files.h>
  38. #endif
  39. /*    #include <OSUtils.h>                                        */
  40.  
  41. #ifndef __QUICKDRAW__
  42. #include <Quickdraw.h>
  43. #endif
  44. /*    #include <QuickdrawText.h>                                    */
  45.  
  46. #ifndef __COMPONENTS__
  47. #include <Components.h>
  48. #endif
  49.  
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53.  
  54. #if PRAGMA_ALIGN_SUPPORTED
  55. #pragma options align=mac68k
  56. #endif
  57.  
  58. #if PRAGMA_IMPORT_SUPPORTED
  59. #pragma import on
  60. #endif
  61.  
  62. typedef OSType FileType;
  63.  
  64. typedef ResType ScrapType;
  65.  
  66. typedef unsigned long TranslationAttributes;
  67.  
  68.  
  69. enum {
  70.     taDstDocNeedsResourceFork    = 1,
  71.     taDstIsAppTranslation        = 2
  72. };
  73.  
  74. struct FileTypeSpec {
  75.     FileType                        format;
  76.     long                            hint;
  77.     TranslationAttributes            flags;                        /* taDstDocNeedsResourceFork, taDstIsAppTranslation*/
  78.     OSType                            catInfoType;
  79.     OSType                            catInfoCreator;
  80. };
  81. typedef struct FileTypeSpec FileTypeSpec;
  82.  
  83. struct FileTranslationList {
  84.     unsigned long                    modDate;
  85.     unsigned long                    groupCount;
  86. /*     unsigned long    group1SrcCount;*/
  87. /*     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);*/
  88. /*  FileTypeSpec    group1SrcTypes[group1SrcCount]*/
  89. /*  unsigned long    group1DstCount;*/
  90. /*  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);*/
  91. /*  FileTypeSpec    group1DstTypes[group1DstCount]*/
  92. };
  93. typedef struct FileTranslationList FileTranslationList;
  94.  
  95. typedef FileTranslationList *FileTranslationListPtr, **FileTranslationListHandle;
  96.  
  97. struct ScrapTypeSpec {
  98.     ScrapType                        format;
  99.     long                            hint;
  100. };
  101. typedef struct ScrapTypeSpec ScrapTypeSpec;
  102.  
  103. struct ScrapTranslationList {
  104.     unsigned long                    modDate;
  105.     unsigned long                    groupCount;
  106. /*     unsigned long        group1SrcCount;*/
  107. /*     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);*/
  108. /*  ScrapTypeSpec        group1SrcTypes[group1SrcCount]*/
  109. /*  unsigned long        group1DstCount;*/
  110. /*     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);*/
  111. /*  ScrapTypeSpec        group1DstTypes[group1DstCount]*/
  112. };
  113. typedef struct ScrapTranslationList ScrapTranslationList;
  114.  
  115. typedef ScrapTranslationList *ScrapTranslationListPtr, **ScrapTranslationListHandle;
  116.  
  117. /* definition of callbacks to update progress dialog*/
  118. typedef long TranslationRefNum;
  119.  
  120. /*****************************************************************************************
  121. *
  122. * This routine sets the advertisement in the top half of the progress dialog.
  123. * It is called once at the beginning of your DoTranslateFile routine.
  124. *
  125. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  126. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  127. *                            Before returning from DoTranslateFile, you should dispose
  128. *                            of the memory.  (Normally, it is in the temp translation heap
  129. *                            so it is cleaned up for you.)
  130. *
  131. * Exit:    returns            noErr, paramErr, or memFullErr
  132. */
  133. extern pascal OSErr SetTranslationAdvertisement(TranslationRefNum refNum, PicHandle advertisement)
  134.  TWOWORDINLINE(0x7002, 0xABFC);
  135. /*****************************************************************************************
  136. *
  137. * This routine updates the progress bar in the progress dialog.
  138. * It is called repeatedly from within your DoTranslateFile routine.
  139. * It should be called often, so that the user will get feedback if he tries to cancel.
  140. *
  141. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  142. *            progress    percent complete (0-100)
  143. *
  144. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  145. *            returns        noErr, paramErr, or memFullErr
  146. */
  147. extern pascal OSErr UpdateTranslationProgress(TranslationRefNum refNum, short percentDone, Boolean *canceled)
  148.  TWOWORDINLINE(0x7001, 0xABFC);
  149. /* ComponentMgr selectors for routines*/
  150.  
  151. enum {
  152.     kTranslateGetFileTranslationList = 0,                        /* component selectors*/
  153.     kTranslateIdentifyFile,
  154.     kTranslateTranslateFile,
  155.     kTranslateGetTranslatedFilename,
  156.     kTranslateGetScrapTranslationList = 10,                        /* skip to scrap routines*/
  157.     kTranslateIdentifyScrap,
  158.     kTranslateTranslateScrap
  159. };
  160.  
  161. /* Routines to implment in a file translation extension*/
  162. typedef pascal ComponentResult (*DoGetFileTranslationListProcPtr)(ComponentInstance self, FileTranslationListHandle translationList);
  163. typedef pascal ComponentResult (*DoIdentifyFileProcPtr)(ComponentInstance self, const FSSpec *theDocument, FileType *docType);
  164. typedef pascal ComponentResult (*DoTranslateFileProcPtr)(ComponentInstance self, TranslationRefNum refNum, const FSSpec *sourceDocument, FileType srcType, long srcTypeHint, const FSSpec *dstDoc, FileType dstType, long dstTypeHint);
  165. typedef pascal ComponentResult (*DoGetTranslatedFilenameProcPtr)(ComponentInstance self, FileType dstType, long dstTypeHint, FSSpec *theDocument);
  166. /* Routine to implement in a scrap translation extension*/
  167. typedef pascal ComponentResult (*DoGetScrapTranslationListProcPtr)(ComponentInstance self, ScrapTranslationListHandle list);
  168. typedef pascal ComponentResult (*DoIdentifyScrapProcPtr)(ComponentInstance self, const void *dataPtr, Size dataLength, ScrapType *dataFormat);
  169. typedef pascal ComponentResult (*DoTranslateScrapProcPtr)(ComponentInstance self, TranslationRefNum refNum, const void *srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint, Handle dstData, ScrapType dstType, long dstTypeHint);
  170.  
  171. #if PRAGMA_IMPORT_SUPPORTED
  172. #pragma import off
  173. #endif
  174.  
  175. #if PRAGMA_ALIGN_SUPPORTED
  176. #pragma options align=reset
  177. #endif
  178.  
  179. #ifdef __cplusplus
  180. }
  181. #endif
  182.  
  183. #endif /* REZ */
  184. #endif /* __TRANSLATIONEXTENSIONS__ */
  185.